package algotithm.leetcode.bytedance.test9;

/**
 * @author zhouyanxiang
 * @Date 2021-03-2021/3/24-23:42
 * @Title 9. 回文数
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int x = 121;
        boolean palindrome = solution.isPalindrome(x);
        System.out.println(palindrome);
    }

    public boolean isPalindrome(int x) {
        if (x < 0 || (x % 10 == 0 && x != 0) ) {
            return false;
        }
        int res = 0;
        while (x > res) {
            res = res * 10 + x % 10;
            x /= 10;
        }
        return x == res || x == res / 10;
    }
}
